<?php
include_once "blog.class.php";

$blog = new Blog;
$blog->load("atom.xml");
	

if (isset($_POST["content"])){
	mb_internal_encoding("UTF-8");

	if(isset($_POST["id"])){
		$blog->updateEntry($_POST["id"],mb_substr(strip_tags($_POST["content"]),0,20), $_POST["content"] );
		$blog->save("atom.xml");

	}
	else{
		$blog->addEntry(mb_substr(strip_tags($_POST["content"]),0,20), $_POST["content"] );
		$blog->save("atom.xml");
	}
}

if (isset($_GET["a"])){
	switch ($_GET["a"]){
	
		case "getshortlist":
			print $blog->getShortList(6);
			break;
		case "loadentry":
			print $blog->loadEntry($_GET["id"]);
			break;
	}

}


?>
